﻿using EntityFrameworkHelper.Migrations;
using System.Reflection;
using System.Web;
using System.Web.Http;
using Web_Entityframework.Models;

namespace Web_Entityframework
{
    public class WebApiApplication : HttpApplication
    {
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);
            //UserContext context = new UserContext();
            DatabaseInitialize();
        }

        /// <summary>
        ///     Databases the initialize.
        /// </summary>
        private static void DatabaseInitialize()
        {
            string file = HttpContext.Current.Server.MapPath("bin/ConfigRegister.dll");
            Assembly assembly = Assembly.LoadFrom(file);
            DatabaseInitializer<UserContext>.AddMapperAssembly(assembly);
            DatabaseInitializer<UserContext>.Initialize();
        }
    }
}